Skip to contentSkip to conversation

Change in openvpn[master]: comp-lz4: Fix types in call to LZ4_decompress_safe

Openvpn-devel In review flichtenheld (Code Review) 2 participants 6 messages Sep 24, 2025 – Sep 26, 2025 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1758731785000.Ie550dd4df65dc4fc13c839c3e745ba96e0c5c564@...2715...

#1 lore raw

Attention is currently required from: plaisthos.

Hello plaisthos,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1215?usp=email

to review the following change.

Change subject: comp-lz4: Fix types in call to LZ4_decompress_safe
......................................................................

comp-lz4: Fix types in call to LZ4_decompress_safe

This is ints all around but we uselessly threw some size_t conversions in there.

Change-Id Ie550dd4df65dc4fc13c839c3e745ba96e0c5c564

---
M src/openvpn/comp-lz4.c

1 file changed, 5 insertions(+), 15 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/15/1215/1

src/openvpn/comp-lz4.c +5 -15
index a78c664..53a5b3f 100644
@@ -88,19 +88,13 @@
     compv2_escape_data_ifneeded(buf);
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"
-#endif
-
 static void
-do_lz4_decompress(size_t zlen_max, struct buffer *work, struct buffer *buf,
+do_lz4_decompress(int zlen_max, struct buffer *work, struct buffer *buf,
                   struct compress_context *compctx)
 {
-    int uncomp_len;
     ASSERT(buf_safe(work, zlen_max));
-    uncomp_len = LZ4_decompress_safe((const char *)BPTR(buf), (char *)BPTR(work), (size_t)BLEN(buf),
-                                     zlen_max);
+    int uncomp_len = LZ4_decompress_safe((const char *)BPTR(buf), (char *)BPTR(work), BLEN(buf),
+                                         zlen_max);
     if (uncomp_len <= 0)
     {
         dmsg(D_COMP_ERRORS, "LZ4 decompression error: %d", uncomp_len);
@@ -118,15 +112,11 @@
     *buf = *work;
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
 static void
 lz4_decompress(struct buffer *buf, struct buffer work, struct compress_context *compctx,
                const struct frame *frame)
 {
-    size_t zlen_max = frame->buf.payload_size;
+    int zlen_max = frame->buf.payload_size;
     uint8_t c; /* flag indicating whether or not our peer compressed */
 
     if (buf->len <= 0)
@@ -163,7 +153,7 @@
 lz4v2_decompress(struct buffer *buf, struct buffer work, struct compress_context *compctx,
                  const struct frame *frame)
 {
-    size_t zlen_max = frame->buf.payload_size;
+    int zlen_max = frame->buf.payload_size;
     uint8_t c; /* flag indicating whether or not our peer compressed */
 
     if (buf->len <= 0)

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1215?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie550dd4df65dc4fc13c839c3e745ba96e0c5c564
Gerrit-Change-Number: 1215
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-MessageType: newchange

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos.

MaxF has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/1215?usp=email )

Change subject: comp-lz4: Fix types in call to LZ4_decompress_safe
......................................................................

Patch Set 1: Code-Review+2

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1215?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie550dd4df65dc4fc13c839c3e745ba96e0c5c564
Gerrit-Change-Number: 1215
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: MaxF <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Fri, 26 Sep 2025 15:34:00 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

#3 lore raw

PATCH 1/1 comp-lz4: Fix types in call to LZ4_decompress_safe

In reply to a message not in the archive

From: Frank Lichtenheld <[email protected]...>

This is ints all around but we uselessly threw some size_t conversions in there.

Change-Id Ie550dd4df65dc4fc13c839c3e745ba96e0c5c564

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1215
---

This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1215
This mail reflects revision 1 of this Change.

Acked-by according to Gerrit (reflected above):
MaxF <[email protected]...>

src/openvpn/comp-lz4.c +5 -15
index a78c664..53a5b3f 100644
@@ -88,19 +88,13 @@
     compv2_escape_data_ifneeded(buf);
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"
-#endif
-
 static void
-do_lz4_decompress(size_t zlen_max, struct buffer *work, struct buffer *buf,
+do_lz4_decompress(int zlen_max, struct buffer *work, struct buffer *buf,
                   struct compress_context *compctx)
 {
-    int uncomp_len;
     ASSERT(buf_safe(work, zlen_max));
-    uncomp_len = LZ4_decompress_safe((const char *)BPTR(buf), (char *)BPTR(work), (size_t)BLEN(buf),
-                                     zlen_max);
+    int uncomp_len = LZ4_decompress_safe((const char *)BPTR(buf), (char *)BPTR(work), BLEN(buf),
+                                         zlen_max);
     if (uncomp_len <= 0)
     {
         dmsg(D_COMP_ERRORS, "LZ4 decompression error: %d", uncomp_len);
@@ -118,15 +112,11 @@
     *buf = *work;
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
 static void
 lz4_decompress(struct buffer *buf, struct buffer work, struct compress_context *compctx,
                const struct frame *frame)
 {
-    size_t zlen_max = frame->buf.payload_size;
+    int zlen_max = frame->buf.payload_size;
     uint8_t c; /* flag indicating whether or not our peer compressed */
 
     if (buf->len <= 0)
@@ -163,7 +153,7 @@
 lz4v2_decompress(struct buffer *buf, struct buffer work, struct compress_context *compctx,
                  const struct frame *frame)
 {
-    size_t zlen_max = frame->buf.payload_size;
+    int zlen_max = frame->buf.payload_size;
     uint8_t c; /* flag indicating whether or not our peer compressed */
 
     if (buf->len <= 0)
#4 lore raw

[Openvpn-devel] [PATCH applied] Re: comp-lz4: Fix types in call to LZ4_decompress_safe

Ints all around... and one set of #pragma gone again :-) - BB t_client tests do test lz4, so the code is excercised.

Your patch has been applied to the master branch.

commit 2682fb541ef9068e9707a3a90c16038e6f516b0f

Author: Frank Lichtenheld
Date:   Fri Sep 26 18:48:39 2025 +0200
     comp-lz4: Fix types in call to LZ4_decompress_safe

     Signed-off-by: Frank Lichtenheld <[email protected]...>
     Acked-by: MaxF <[email protected]...>
     Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1215
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg33228.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#5 lore raw
In reply to a message not in the archive

cron2 has uploaded a new patch set (#2) to the change originally created by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1215?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by MaxF

Change subject: comp-lz4: Fix types in call to LZ4_decompress_safe
......................................................................

comp-lz4: Fix types in call to LZ4_decompress_safe

This is ints all around but we uselessly threw some size_t conversions in there.

Change-Id Ie550dd4df65dc4fc13c839c3e745ba96e0c5c564

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1215
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg33228.html

---
M src/openvpn/comp-lz4.c

1 file changed, 5 insertions(+), 15 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/15/1215/2

src/openvpn/comp-lz4.c +5 -15
index a78c664..53a5b3f 100644
@@ -88,19 +88,13 @@
     compv2_escape_data_ifneeded(buf);
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"
-#endif
-
 static void
-do_lz4_decompress(size_t zlen_max, struct buffer *work, struct buffer *buf,
+do_lz4_decompress(int zlen_max, struct buffer *work, struct buffer *buf,
                   struct compress_context *compctx)
 {
-    int uncomp_len;
     ASSERT(buf_safe(work, zlen_max));
-    uncomp_len = LZ4_decompress_safe((const char *)BPTR(buf), (char *)BPTR(work), (size_t)BLEN(buf),
-                                     zlen_max);
+    int uncomp_len = LZ4_decompress_safe((const char *)BPTR(buf), (char *)BPTR(work), BLEN(buf),
+                                         zlen_max);
     if (uncomp_len <= 0)
     {
         dmsg(D_COMP_ERRORS, "LZ4 decompression error: %d", uncomp_len);
@@ -118,15 +112,11 @@
     *buf = *work;
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
 static void
 lz4_decompress(struct buffer *buf, struct buffer work, struct compress_context *compctx,
                const struct frame *frame)
 {
-    size_t zlen_max = frame->buf.payload_size;
+    int zlen_max = frame->buf.payload_size;
     uint8_t c; /* flag indicating whether or not our peer compressed */
 
     if (buf->len <= 0)
@@ -163,7 +153,7 @@
 lz4v2_decompress(struct buffer *buf, struct buffer work, struct compress_context *compctx,
                  const struct frame *frame)
 {
-    size_t zlen_max = frame->buf.payload_size;
+    int zlen_max = frame->buf.payload_size;
     uint8_t c; /* flag indicating whether or not our peer compressed */
 
     if (buf->len <= 0)

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1215?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie550dd4df65dc4fc13c839c3e745ba96e0c5c564
Gerrit-Change-Number: 1215
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: MaxF <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: newpatchset

#6 lore raw
In reply to a message not in the archive

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1215?usp=email )

Change subject: comp-lz4: Fix types in call to LZ4_decompress_safe
......................................................................

comp-lz4: Fix types in call to LZ4_decompress_safe

This is ints all around but we uselessly threw some size_t conversions in there.

Change-Id Ie550dd4df65dc4fc13c839c3e745ba96e0c5c564

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1215
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg33228.html

---
M src/openvpn/comp-lz4.c

1 file changed, 5 insertions(+), 15 deletions(-)
src/openvpn/comp-lz4.c +5 -15
index a78c664..53a5b3f 100644
@@ -88,19 +88,13 @@
     compv2_escape_data_ifneeded(buf);
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"
-#endif
-
 static void
-do_lz4_decompress(size_t zlen_max, struct buffer *work, struct buffer *buf,
+do_lz4_decompress(int zlen_max, struct buffer *work, struct buffer *buf,
                   struct compress_context *compctx)
 {
-    int uncomp_len;
     ASSERT(buf_safe(work, zlen_max));
-    uncomp_len = LZ4_decompress_safe((const char *)BPTR(buf), (char *)BPTR(work), (size_t)BLEN(buf),
-                                     zlen_max);
+    int uncomp_len = LZ4_decompress_safe((const char *)BPTR(buf), (char *)BPTR(work), BLEN(buf),
+                                         zlen_max);
     if (uncomp_len <= 0)
     {
         dmsg(D_COMP_ERRORS, "LZ4 decompression error: %d", uncomp_len);
@@ -118,15 +112,11 @@
     *buf = *work;
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
 static void
 lz4_decompress(struct buffer *buf, struct buffer work, struct compress_context *compctx,
                const struct frame *frame)
 {
-    size_t zlen_max = frame->buf.payload_size;
+    int zlen_max = frame->buf.payload_size;
     uint8_t c; /* flag indicating whether or not our peer compressed */
 
     if (buf->len <= 0)
@@ -163,7 +153,7 @@
 lz4v2_decompress(struct buffer *buf, struct buffer work, struct compress_context *compctx,
                  const struct frame *frame)
 {
-    size_t zlen_max = frame->buf.payload_size;
+    int zlen_max = frame->buf.payload_size;
     uint8_t c; /* flag indicating whether or not our peer compressed */
 
     if (buf->len <= 0)

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1215?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie550dd4df65dc4fc13c839c3e745ba96e0c5c564
Gerrit-Change-Number: 1215
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: MaxF <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: merged